find average of array elements